<template>
  <div class="pc" v-if="store.state.isPc">
    <div class="about">
      <div class="container">
        <div class="navtext">{{ $route.query.name }}</div>
           <div class="radiobtnbox">
          <el-radio-group v-model="classid" size="large" class="radiobtn" v-if=" classlist.value?.item?.length>0" @change="searchFun">
            <el-radio-button :label="item.id" v-for="(item,index) in  classlist.value.item" :key="item.id">{{item.class_name}}</el-radio-button>
          </el-radio-group>
        </div>
        <ul class="list">
          <li
            v-for="item in newslist.value"
            :key="item"
            @click="godetails(item)"
          >
            <div class="dian"></div>
            <div class="title">
              <h3>{{ item.name }}</h3>
            </div>
          </li>
        </ul>
        <div class="page">
          <el-pagination
            :current-page="page"
            :page-size="pagesize"
            layout="prev, pager, next"
            background
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
      <div class="foot">
        <div class="top">
          <p>指导单位：文化和旅游部科技教育司</p>
          <p>
            主办单位：全国文化艺术职业教育教学指导委员会、深圳市文化广电旅游体育局
          </p>
          <p>
            承办单位：全国文化艺术职业教育教学指导委员会对外交流与合作专委会、教学质量评价与保障专委会、深圳艺术学校、浙江艺术学校
          </p>
          <p>技术支持单位：广州市晨旭教育评估有限公司</p>
        </div>
        <div class="bottom">
          <p>ICP备05052393号-11</p>
        </div>
      </div>
    </div>
  </div>
  <div class="mob" v-else>
    <div class="about">
      <div class="container">
        <div class="headbox">
           <div class="navtext">{{ $route.query.name }}</div>
          <div class="radiobtnbox">
            
          <el-radio-group v-model="classid"  class="radiobtn" v-if=" classlist.value?.item?.length>0" @change="searchFun">
            <el-radio-button :label="item.id" v-for="(item,index) in  classlist.value.item" :key="item.id">{{item.class_name}}</el-radio-button>
          </el-radio-group>
        </div>
        </div>
        <ul class="list">
          <li
            v-for="item in newslist.value"
            :key="item"
            @click="godetails(item)"
          >
            <div class="dian"></div>
            <div class="title">
              <p>{{ item.name }}</p>
            </div>
          </li>
        </ul>
        <div class="page">
          <el-pagination
            :current-page="page"
            :page-size="pagesize"
            layout="prev, pager, next"
            background
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
      <div class="foot">
        <p>指导单位：文化和旅游部科技教育司</p>
        <p>
          主办单位：全国文化艺术职业教育教学指导委员会、深圳市文化广电旅游体育局
        </p>
        <p>
          承办单位：全国文化艺术职业教育教学指导委员会对外交流与合作专委会、教学质量评价与保障专委会、深圳艺术学校、浙江艺术学校
        </p>
        <p>技术支持单位：广州市晨旭教育评估有限公司</p>
        <p>ICP备05052393号-11</p>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { Search, View } from "@element-plus/icons-vue";
import { useRoute, useRouter } from "vue-router";
import { debounce, throttle } from "lodash";
import { timestampToTime } from "../../utils/utils";
import { defineComponent, reactive, watch, ref, onMounted } from "vue";
import { newsLists,allNewsClass } from "../../api/api";
import { useStore } from "vuex";
let store = useStore();
let $route = useRoute();
let $router = useRouter();
let search = ref($route.query.search ? $route.query.search : "");
let total = ref(0);
let page = ref(1);
let pagesize = ref(10);

onMounted(() => {
  // getlist();
  getclass()
});

let classid = ref($route.query.class_id)
//---------------------------------------------------------------------------获取下载列表
let classlist:any = reactive({value:{}})
const getclass = ()=>{
  allNewsClass().then((res=>{
    res.data.forEach((item,index)=>{
      if($route.query.class_id==item.id){
        classlist.value = item
        console.log(  classlist.value)
        if(item.item.length>0){
          classid.value = item.item[0]?.id
           getlist()
        }else{
           getlist()
        }
      }
    })
  }))
}


let newslist: any = reactive({ value: [] });
const getlist = () => {
  console.log($route)
  newsLists({
    class_id:classid.value,
    limit: pagesize.value,
    page: page.value,
  }).then((res) => {
    newslist.value = res.data;
    total.value = res.paging.sum;
    window.scrollTo(0, 0);
  });
};

//---------------------------------------------------------------------------end获取下载列表

//---------------------------------------------------------------------------获取搜索

const searchFun = debounce(function () {
  page.value = 1;
  getlist();
}, 500);

const godetails = (value: any) => {
  window.open(
    `/downloaddetails?id=${value.id}&class_id=${$route.query.class_id}&name=${$route.query.name}`
  );
};

//---------------------------------------------------------------------------end获取搜索

const handleSizeChange = () => {};

const handleCurrentChange = (value: number) => {
  page.value = value;
  getlist();
};
</script>

<style lang="scss" scoped>
.pc {
  .about {
    background: white;
    .banners {
      height: 260px;
      width: 100%;
      position: relative;
      img {
        width: 100%;
        height: 100%;
      }
      .top-info {
        margin-bottom: 0;
        line-height: 42px;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        color: #fff;
        .top-text {
          height: 58px;
          font-size: 45px;
          font-family: Source Han Sans CN-Bold, Source Han Sans CN;
          font-weight: 700;
          color: #ffffff;
          line-height: 36px;
        }
        .btn {
          background-image: linear-gradient(-135deg, #bd864c, #f5c989);
          border-radius: 27px;
          color: #773c07;
          border: none;
          text-align: center;
        }
      }
    }
    .container {
      margin: 0 auto;
      margin-top: 0;
      background: white;
      border-radius: 5px;
      padding: 0 100px;
      width: 1400px;
      position: relative;
      min-height: 800px;
      padding-top: 44px;
      .navtext {
        font-size: 30px;
        font-family: Source Han Sans-Bold, Source Han Sans;
        font-weight: 700;
        color: #251b95;
        line-height: 43px;
        width: 60%;
        display: inline-block;
      }
      .radiobtnbox{
        float: right;
      }
      .tab {
        // display: flex;
        display: none;
        li {
          height: 50px;
          padding: 12px 25px;
          color: #7c7c7c;
          background: #f4f4f4;
          font-size: 20px;
          margin-left: 20px;
          cursor: pointer;
          &:nth-child(1) {
            margin-left: 0;
          }
        }
        .active {
          background: #2c24a1;
          color: white;
        }
      }
      .list {
        margin-top: 20px;
        border-top: 2px solid #494dd4;
        li {
          height: 118px;
          border-bottom: 1px solid #e5e5e5;
          padding: 18px 15px;
          padding-left: 40px;
          position: relative;
          .dian {
            position: absolute;
            width: 14px;
            height: 14px;
            background: #494dd4;
            opacity: 1;
            border-radius: 50%;
            left: 13px;
            top: 50%;
            transform: translateY(-50%);
          }
          &:hover {
            cursor: pointer;
            background: white;
            .download {
              .iconfont {
                color: #2c24a1;
              }
            }
          }
          .title {
            width: 100%;
            height: 100%;
            float: left;
            position: relative;
            h3 {
              width: 100%;
              position: absolute;
              left: 0;
              top: 50%;
              transform: translateY(-50%);
              font-size: 22px;
              font-family: Source Han Sans-Medium, Source Han Sans;
              font-weight: 500;
              color: #333333;
              line-height: 30px;
              overflow: hidden;
              text-overflow: ellipsis;
              display: -webkit-box;
              -webkit-line-clamp: 2;
              text-overflow: ellipsis;
              overflow: hidden;
              -webkit-box-orient: vertical;

              &:hover {
                color: #494dd4;
              }
            }
          }
          .download {
            width: 140px;
            height: 100%;

            float: right;
            text-align: center;
            line-height: 72px;
            .iconfont {
              font-size: 30px;
            }
          }
        }
      }
      .page {
        height: 100px;
        position: relative;
        display: flex;
        justify-content: center;
        align-items: center;
        :deep(.el-pagination) {
          .is-active {
            background: linear-gradient(269deg, #7b39c4 9%, #3226ba 100%);
            border-radius: 50%;
          }
          .btn-next,
          .btn-prev,
          .el-pager li {
            background-color: #251b9500 !important;
          }
        }
      }
    }
  }

  .foot {
    width: 100%;
    height: 270px;
    background: url("../../assets/footbg.png") no-repeat;
    background-size: 100% 100%;
    .top {
      height: 220px;
      width: 1400px;
      margin: 0 auto;
      box-sizing: border-box;
      padding-top: 40px;
      p {
        font-size: 18px;
        font-family: Source Han Sans-Regular, Source Han Sans;
        font-weight: 400;
        color: #ffffff;
        line-height: 36px;
      }
    }
    .bottom {
      height: 48px;
      border-top: 1px solid #dadada;
      p {
        line-height: 48px;
        text-align: center;
        font-size: 18px;
        font-family: Source Han Sans-Regular, Source Han Sans;
        font-weight: 400;
        color: #ffffff;
      }
    }
  }
}
.mob {
  .about {
    background: white;
    .banners {
      height: 16.25rem;
      width: 100%;
      position: relative;
      img {
        width: 100%;
        height: 100%;
      }
      .top-info {
        margin-bottom: 0;
        line-height: 2.625rem;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        color: #fff;
        .top-text {
          height: 3.625rem;
          font-size: 2.8125rem;
          font-family: Source Han Sans CN-Bold, Source Han Sans CN;
          font-weight: 700;
          color: #ffffff;
          line-height: 2.25rem;
        }
        .btn {
          background-image: linear-gradient(-135deg, #bd864c, #f5c989);
          border-radius: 1.6875rem;
          color: #773c07;
          border: none;
          text-align: center;
        }
      }
    }
    .container {
      width: 46.875rem;
      margin: 0 auto;
      margin-top: 0;
      background: white;
      border-radius: 0.3125rem;
      padding: 0 2.5rem;
      position: relative;
      padding-top: 2.75rem;
      .headbox{
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
      .navtext {
        font-size: 1.875rem;
        font-family: Source Han Sans-Bold, Source Han Sans;
        font-weight: 700;
        color: #251b95;
        line-height: 2.6875rem;
        display: inline-block;
      }
      .radiobtnbox{
        float: right;
      }
      .tab {
        // display: flex;
        display: none;
        li {
          height: 3.125rem;
          padding: 0.75rem 1.5625rem;
          color: #7c7c7c;
          background: #f4f4f4;
          font-size: 1.25rem;
          margin-left: 1.25rem;
          cursor: pointer;
          &:nth-child(1) {
            margin-left: 0;
          }
        }
        .active {
          background: #2c24a1;
          color: white;
        }
      }
      .list {
        margin-top: 1.25rem;
        border-top: 2px solid #494dd4;
        width: 100%;
        li {
          width: 100%;
          height: 7.375rem;
          border-bottom: 1px solid #e5e5e5;
          padding: 1.125rem 0.9375rem;
          padding-left: 2.5rem;
          position: relative;
          .dian {
            position: absolute;
            width: 0.875rem;
            height: 0.875rem;
            background: #494dd4;
            opacity: 1;
            border-radius: 50%;
            left: 0.8125rem;
            top: 50%;
            transform: translateY(-50%);
          }
          &:hover {
            cursor: pointer;
            background: white;
            .download {
              .iconfont {
                color: #2c24a1;
              }
            }
          }
          .title {
            height: 100%;
            float: left;
            width: 100%;
            position: relative;
            p {
              position: absolute;
              left: 2rem;
              top: 50%;
              transform: translateY(-50%);
              font-size: 1.625rem;
              font-family: Source Han Sans-Medium, Source Han Sans;
              font-weight: 500;
              color: #333333;
              line-height: 1.8rem;
              width: calc(100% - 3.125rem);
              &:hover {
                color: #494dd4;
              }
            }
          }
          .download {
            width: 8.75rem;
            height: 100%;

            float: right;
            text-align: center;
            line-height: 4.5rem;
            .iconfont {
              font-size: 1.875rem;
            }
          }
        }
      }
      .page {
        height: 100px;
        position: relative;
        display: flex;
        justify-content: center;
        align-items: center;
        :deep(.el-pagination) {
          .is-active {
            background: linear-gradient(269deg, #7b39c4 9%, #3226ba 100%);
            border-radius: 50%;
          }
          .btn-next,
          .btn-prev,
          .el-pager li {
            background-color: #251b9500 !important;
          }
        }
      }
    }
  }
  .foot {
    background: #3c3daa;
    width: 46.875rem;
    height: 15.625rem;
    color: rgb(245, 245, 245);
    font-size: 1.125rem;
    padding: 0 1.5rem;
    padding-top: 2.1875rem;
    line-height: 1.875rem;
  }
}
</style>
